home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch5 / PickPtr.frm < prev    next >
Text File  |  1999-04-10  |  2KB  |  58 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  3. Begin VB.Form frmPickPtr 
  4.    Caption         =   "PickPtr"
  5.    ClientHeight    =   1215
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   1935
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   1215
  11.    ScaleWidth      =   1935
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton cmdPickPrinter 
  14.       Caption         =   "Pick Printer"
  15.       Height          =   495
  16.       Left            =   360
  17.       TabIndex        =   0
  18.       Top             =   360
  19.       Width           =   1215
  20.    End
  21.    Begin MSComDlg.CommonDialog dlgPrinter 
  22.       Left            =   1800
  23.       Top             =   240
  24.       _ExtentX        =   847
  25.       _ExtentY        =   847
  26.       _Version        =   393216
  27.    End
  28. End
  29. Attribute VB_Name = "frmPickPtr"
  30. Attribute VB_GlobalNameSpace = False
  31. Attribute VB_Creatable = False
  32. Attribute VB_PredeclaredId = True
  33. Attribute VB_Exposed = False
  34. Option Explicit
  35.  
  36. ' Let the user select a printer.
  37. Private Sub cmdPickPrinter_Click()
  38.     dlgPrinter.CancelError = True
  39.  
  40.     On Error Resume Next
  41.     dlgPrinter.ShowPrinter
  42.     If Err.Number = cdlCancel Then
  43.         ' The user canceled. Do nothing.
  44.         Exit Sub
  45.     ElseIf Err.Number <> 0 Then
  46.         ' Unexpected error. Report it.
  47.         MsgBox "Error " & Format$(Err.Number) & _
  48.             " selecting printer." & vbCrLf & _
  49.             Err.Description
  50.         Exit Sub
  51.     End If
  52.     On Error GoTo 0
  53.  
  54.     ' Print to the newly selected Printer object.
  55.     Printer.Print "Selected printer: " & Printer.DeviceName
  56.     Printer.EndDoc
  57. End Sub
  58.